<template>
<div>
  <h1>支付宝支付</h1>
  <h2>订单名称：{{this.$store.state.foodorder.name}}</h2>
  <h2>金额：{{this.$store.state.foodorder.price}} 元</h2>
  <div><van-button style="background-color: red" @click="sendPay()">确认支付</van-button></div>
</div>
</template>

<script>
export default {
  name: "Pay",
  methods:{
    sendPay(){
      //发起创建支付请求
      var obj={
        money: this.$store.state.foodorder.price,
        oid: this.$store.state.foodorder.oid,
      }

      this.axios.post("/api/pay/create.do",obj).then(res=>{
        if(res.data.code==200){
          //成功
          document.write("'"+res.data.data+"'");
        }else{

        }
      })
    }
  }
}
</script>

<style scoped>

</style>